package cn.ac.sec.framework.db;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;

/**
 * @author sec
 * @version v1.0
 */
public class SettingManager {
	/**
	 * FILE_PATH
	 */
	private static String FILE_PATH = "/jdbc.properties";
	/**
	 * INSTANCE
	 */
	private static SettingManager INSTANCE = new SettingManager();

	/**
	 * @return
	 */
	public static SettingManager getInstance() {
		return INSTANCE;
	}

	/**
	 * config
	 */
	private Configuration config;

	/**
     * 
     */
	private SettingManager() {
		try {
            FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
            PropertiesConfiguration configuration = new PropertiesConfiguration(
                    SettingManager.class.getResource(FILE_PATH));
            configuration.setReloadingStrategy(strategy);
            this.config = configuration;
        } catch (ConfigurationException e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
        }
	}

	/**
	 * 用于读取配置文件
	 * 
	 * @return
	 */
	public Configuration getConfig() {
		return this.config;
	}

}
